<?php
declare (strict_types=1);

namespace app\user\service\user\admin;

use app\common\service\BaseService;
use app\user\logic\user\admin\Balance as BalanceLogic;
use think\annotation\Inject;
use think\facade\Request;

/**
 * 用户余额接口类
 */
class Balance extends BaseService
{

    /**
     * @Inject()
     *
     * @var BalanceLogic
     */
    protected $balanceLogic;

    /**
     * 余额信息
     * Author   亓官雨树<lucky.max@foxmail.com>
     * Date 2020-04-20
     *
     * @param string $value [description]
     */
    public function info()
    {
        $balance = $this->balanceLogic->getUserBalanceInfo();
        return $this->parseToData($balance, 1, '获取成功');
    }
    //
    // public function update()
    // {
    //     $param   = Request::put();
    //     $balance = $this->balanceLogic->updateUserBalance($param);
    //
    //     return $this->parseToData($balance, 1, '变更成功');
    // }

    /**
     * 设置用户余额
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2021/9/8
     *
     * @param int $userId
     * @return \think\Response
     */
    public function setBalance(int $userId)
    {
        $balance = Request::put('balance');
        $this->balanceLogic->setUserBalance($userId, $balance);

        return $this->parseTodata([], 1, '变更成功');
    }
}
